#include <stdio.h>
int main(void)
{
    int days, day;
    printf("Enter number of days in month: ");
    scanf("%d", &days);
    printf("Enter starting day of the week (1=Sun, 7=Sat): ");
    scanf("%d", &day);
    day = day % 7;
    if (day == 0)
        day = 7;
    for (int i = 1; i < day; i++) {
        printf("   ");
    }
    for (int i = 1; i <= days; i++) {
        if (day == 1 && i > 1)
            printf("\n");
        printf("%2d", i);
        day++;
        if (day > 7) {
            day = 1;
        }
        else
            printf(" ");
    }
    printf("\n");
    return 0;
}